//
//  TYHomeFunctionDimeStoreCell.m
//  爱鲜蜂
//
//  Created by 李田 on 16/11/19.
//  Copyright © 2016年 tianyao. All rights reserved.
//

#import "LBHomeFunctionDimeStoreCell.h"
#import "LBBtnView.h"
@implementation LBHomeFunctionDimeStoreCell

- (instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    
    return self;
}

- (void)setupUI{
    
    self.backgroundColor = [UIColor whiteColor];
    //    MARK: 标题
    UILabel *titleL = [UILabel cz_labelWithText:@"便利店" fontSize:17 color:[UIColor blackColor]];
    
    [self.contentView addSubview:titleL];
    //    MARK: 标题图片
    UILabel *iconL = [UILabel cz_labelWithText:@"一小时送到家" fontSize:15 color:[UIColor cz_colorWithHex:0xfdd000]];
    
    [self.contentView addSubview:iconL];
    
    UIImageView *titleImgV = [[UIImageView alloc] init];
    
    titleImgV.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://img01.bqstatic.com//upload/activity/201609232046093.png@90Q.png"]]];
    [self.contentView addSubview:titleImgV];

    //    MARK: hotBtn
    UIButton *hotBtn = [[UIButton alloc] init];
    [hotBtn setImage:[UIImage imageNamed: @"rexiao"] forState:UIControlStateNormal];
    
    [hotBtn addTarget:self action:@selector(clickHotBtn:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:hotBtn];
    //    MARK: priceBtn
    UIButton *priceBtn = [[UIButton alloc] init];
    [priceBtn setImage:[UIImage imageNamed:@"tejia"] forState:UIControlStateNormal];

    [priceBtn addTarget:self action:@selector(clickPriceBtn:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:priceBtn];
    //    MARK:btnV
    
    NSArray *imageNameArr = @[@"001", @"002", @"003", @"004"];
    
    NSArray *titleArr = @[@"优选水果",@"牛奶面包",@"饮料酒水",@"更多"];
    LBBtnView *btnV = [[LBBtnView alloc] initWithImageNameArr:imageNameArr titleArr:titleArr];
    
    [self.contentView addSubview:btnV];
    
    //    MARK: 布局
    [titleImgV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView);
        make.height.mas_equalTo(60);
        make.width.mas_equalTo(375);
    }];
    
    [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(130);
        make.top.mas_equalTo(20);
    }];
    
    [iconL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(titleL.mas_right).offset(20);
        make.top.equalTo(titleL.mas_top);
    }];
    
    [hotBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(titleL.mas_bottom).offset(20);
        make.left.mas_equalTo(10);
        make.size.mas_equalTo(CGSizeMake(173, 70));
    }];

    [priceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(hotBtn.mas_top);
        make.right.mas_equalTo(-10);
        make.size.mas_equalTo(CGSizeMake(173, 70));
    }];
    
    [btnV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.contentView);
        make.height.mas_equalTo(80);
        make.top.equalTo(hotBtn.mas_bottom).offset(10);
    }];
    
}

- (void)clickHotBtn: (UIButton *)hotBtn{
    
    NSLog(@"热销榜");
}

- (void)clickPriceBtn: (UIButton *)priceBtn{
    
    NSLog(@"天天特价");
}

@end
